package com.opcode.nebulamobil.utility;

import java.util.Calendar;
import java.util.Random;

/**
 * 
 * @author Okan ERDO�AN
 *
 * 26 Tem 2014
 */
public class UniqueIdCreator {
	
	/**
	 * 
	 * @return
	 */
	public static int createUniqueID(){
		int id=0;
		String idString;
		idString=String.valueOf(getCurrentTimeId())+String.valueOf(createRandomInt());
		id=Integer.valueOf(idString);	
		return id;
	}
	
	
	/**
	 * Sistemin anl�k zaman bilgilerini al�r.
	 * @return
	 */
	private static int getCurrentTimeId(){
		Calendar c = Calendar.getInstance(); 
		int seconds = c.get(Calendar.SECOND);
		int minute=c.get(Calendar.MINUTE);
		int hour=c.get(Calendar.HOUR);

		String timeIdString=String.valueOf(hour)+String.valueOf(minute)+String.valueOf(seconds);
		int timeId=Integer.valueOf(timeIdString);
		return timeId;
	}
	
	
	/**
	 * Bu metod �a�r�ld��� zaman maksimum 10000'e kadar olmak �zere rastgele bir say� �retir.
	 * @return
	 */
	private static int createRandomInt(){
		Random random=new Random();
		return random.nextInt(10000);
	}

}
